package com.xiaoshuidi.cloud.module.contract.service.contract.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.contract.OrderLateFeeVo;
import com.xiaoshuidi.cloud.module.contract.dal.mysql.contract.OrderLateFeeMapper;
import com.xiaoshuidi.cloud.module.contract.service.contract.OrderLateFeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @BelongsProject: lease-module-contract
 * @BelongsPackage: com.xiaoshuidi.cloud.module.contract.service.contract.impl
 * @Author: James
 * @CreateTime: 2023-11-13  17:27
 * @Description: 滞纳金配置
 * @Version: 1.0
 */
@Service
@Slf4j
public class OrderLateFeeServiceImpl extends ServiceImpl<OrderLateFeeMapper, OrderLateFeeVo> implements OrderLateFeeService {

    @Resource
    private OrderLateFeeMapper orderLateFeeMapper;
    @Override
    public OrderLateFeeVo getOrderLateFee(Long apartmentId) {
        LambdaQueryWrapper<OrderLateFeeVo> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(OrderLateFeeVo::getApartmentId,apartmentId);
        OrderLateFeeVo orderLateFeeVo = orderLateFeeMapper.selectOne(wrapper);
        return orderLateFeeVo;
    }

    @Override
    public OrderLateFeeVo getIsOrderFee(Long apartmentId) {
        LambdaQueryWrapper<OrderLateFeeVo> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(OrderLateFeeVo::getApartmentId,apartmentId);
        wrapper.eq(OrderLateFeeVo::getIsSwitch,true);
        log.info("查询滞纳金配置信息开始");
        OrderLateFeeVo orderLateFeeVo = orderLateFeeMapper.selectOne(wrapper);
        log.info("查询滞纳金配置信息结束");
        return orderLateFeeVo;
    }
}
